{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Example file showing a basic pygame \"game loop\"\n",
    "import pygame\n",
    "\n",
    "# pygame setup\n",
    "pygame.init()\n",
    "screen = pygame.display.set_mode((1280, 720))\n",
    "clock = pygame.time.Clock()\n",
    "running = True\n",
    "\n",
    "while running:\n",
    "    # poll for events\n",
    "    # pygame.QUIT event means the user clicked X to close your window\n",
    "    for event in pygame.event.get():\n",
    "        if event.type == pygame.QUIT:\n",
    "            running = False\n",
    "\n",
    "    # fill the screen with a color to wipe away anything from last frame\n",
    "    screen.fill(\"purple\")\n",
    "\n",
    "    # RENDER YOUR GAME HERE\n",
    "\n",
    "    # flip() the display to put your work on screen\n",
    "    pygame.display.flip()\n",
    "\n",
    "    clock.tick(60)  # limits FPS to 60\n",
    "\n",
    "pygame.quit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "pygame 2.5.2 (SDL 2.28.2, Python 3.10.10)\n",
      "Hello from the pygame community. https://www.pygame.org/contribute.html\n"
     ]
    }
   ],
   "source": [
    "import pygame\n",
    "import time\n",
    "\n",
    "pygame.init()\n",
    "screen = pygame.display.set_mode((800, 600))\n",
    "clock = pygame.time.Clock()\n",
    "image = pygame.image.load(\"init.png\")\n",
    "running = True\n",
    "\n",
    "\n",
    "def get_new_image():\n",
    "\n",
    "    return \"update.png\"\n",
    "\n",
    "\n",
    "while running:\n",
    "    for event in pygame.event.get():\n",
    "        if event.type == pygame.QUIT:\n",
    "            running = False\n",
    "    new_image = get_new_image()\n",
    "    image = pygame.image.load(new_image)\n",
    "    screen.blit(image, (0, 0))\n",
    "    pygame.display.flip()\n",
    "    clock.tick(30)\n",
    "\n",
    "pygame.quit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Example file showing a circle moving on screen\n",
    "import pygame\n",
    "\n",
    "# pygame setup\n",
    "pygame.init()\n",
    "screen = pygame.display.set_mode((1280, 720))\n",
    "clock = pygame.time.Clock()\n",
    "running = True\n",
    "dt = 0\n",
    "\n",
    "player_pos = pygame.Vector2(screen.get_width() / 2, screen.get_height() / 2)\n",
    "\n",
    "while running:\n",
    "    # poll for events\n",
    "    # pygame.QUIT event means the user clicked X to close your window\n",
    "    for event in pygame.event.get():\n",
    "        if event.type == pygame.QUIT:\n",
    "            running = False\n",
    "\n",
    "    # fill the screen with a color to wipe away anything from last frame\n",
    "    screen.fill(\"purple\")\n",
    "\n",
    "    pygame.draw.circle(screen, \"red\", player_pos, 40)\n",
    "\n",
    "    keys = pygame.key.get_pressed()\n",
    "    if keys[pygame.K_w]:\n",
    "        player_pos.y -= 300 * dt\n",
    "    if keys[pygame.K_s]:\n",
    "        player_pos.y += 300 * dt\n",
    "    if keys[pygame.K_a]:\n",
    "        player_pos.x -= 300 * dt\n",
    "    if keys[pygame.K_d]:\n",
    "        player_pos.x += 300 * dt\n",
    "\n",
    "    # flip() the display to put your work on screen\n",
    "    pygame.display.flip()\n",
    "\n",
    "    # limits FPS to 60\n",
    "    # dt is delta time in seconds since last frame, used for framerate-\n",
    "    # independent physics.\n",
    "    dt = clock.tick(60) / 1000\n",
    "\n",
    "pygame.quit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
